src/ostbuild/pyostbuild/builtin_chroot_compile_one.py \
src/ostbuild/pyostbuild/builtin_chroot_run_triggers.py \
src/ostbuild/pyostbuild/builtin_compile_one.py \
- src/ostbuild/pyostbuild/builtin_gen_snapshot.py \
+ src/ostbuild/pyostbuild/builtin_query_content.py \
src/ostbuild/pyostbuild/builtin_resolve.py \
src/ostbuild/pyostbuild/builtin_status.py \
src/ostbuild/pyostbuild/builtins.py \
run_sync(args, cwd=cwd, fatal_on_error=False, keep_stdin=True)
fatal("Exiting after debug shell")
- def _resolve_component_meta(self, component_meta):
- result = dict(component_meta)
- orig_src = component_meta['src']
-
- did_expand = False
- for (vcsprefix, expansion) in self.manifest['vcsconfig'].iteritems():
- prefix = vcsprefix + ':'
- if orig_src.startswith(prefix):
- result['src'] = expansion + orig_src[len(prefix):]
- did_expand = True
- break
-
- name = component_meta.get('name')
- if name is None:
- if did_expand:
- src = orig_src
- idx = src.rindex(':')
- name = src[idx+1:]
- else:
- src = result['src']
- idx = src.rindex('/')
- name = src[idx+1:]
- if name.endswith('.git'):
- name = name[:-4]
- name = name.replace('/', '-')
- result['name'] = name
-
- if 'branch' not in result:
- result['branch'] = 'master'
-
- return result
-
def _build_one_component(self, name, component):
branch = component['branch']
architecture = component['architecture']
'--union', '--subpath=' + subtree,
branch_rev, compose_rootdir])
- contents_path = os.path.join(compose_rootdir, 'manifest.json')
+ contents_path = os.path.join(compose_rootdir, 'contents.json')
f = open(contents_path, 'w')
json.dump(metadata, f, indent=4, sort_keys=True)
f.close()
self.args = args
self.parse_config()
- self.parse_components_and_targets()
+ self.parse_snapshot()
self.buildopts = BuildOptions()
self.buildopts.shell_on_failure = args.shell_on_failure
if args.recompose:
pass
elif len(args.components) == 0:
- tsorted = buildutil.tsort_components(self.components, 'build-depends')
+ tsorted = buildutil.tsort_components(self.snapshot['components'], 'build-depends')
tsorted.reverse()
build_component_order = tsorted
else:
fatal("Can't specify --start-at with component list")
for name in args.components:
found = False
- component = self.components.get(name)
+ component = self.snapshot['components'].get(name)
if component is None:
fatal("Unknown component %r" % (name, ))
build_component_order.append(name)
start_at_index = 0
for component_name in build_component_order[start_at_index:]:
- component = self.components.get(component_name)
+ component = self.snapshot['components'].get(component_name)
self._build_one_component(component_name, component)
- for target in self.targets['targets']:
+ for target in self.snapshot['targets']:
self._compose(target)
builtins.register(OstbuildBuild)
self.args = args
self.parse_config()
- self.parse_components_and_targets()
+ self.parse_snapshot()
if len(args.components) > 0:
checkout_components = args.components
for component_name in checkout_components:
found = False
- component = self.components.get(component_name)
+ component = self.snapshot['components'].get(component_name)
if component is None:
fatal("Unknown component %r" % (component_name, ))
(keytype, uri) = buildutil.parse_src_key(component['src'])
short_description = "Build artifacts from the current source directory in a chroot"
def _compose_buildroot(self, component_name, dirpath):
- dependencies = buildutil.build_depends(component_name, self.components)
- component = self.components.get(component_name)
+ components = self.snapshot['components']
+ dependencies = buildutil.build_depends(component_name, components)
+ component = components.get(component_name)
- base_devel_name = 'bases/%s-%s-%s' % (self.manifest['base-prefix'],
+ base_devel_name = 'bases/%s-%s-%s' % (self.snapshot['base-prefix'],
component['architecture'],
'devel')
checkout_trees = [(base_devel_name, '/')]
args = parser.parse_args(argv)
self.parse_config()
- self.parse_components_and_targets()
+ self.parse_snapshot()
if args.name:
component_name = args.name
parentparent = os.path.dirname(parent)
component_name = '%s/%s/%s' % tuple(map(os.path.basename, [parentparent, parent, cwd]))
- component = self.components.get(component_name)
+ components = self.snapshot['components']
+ component = components.get(component_name)
if component is None:
fatal("Couldn't find component '%s' in manifest" % (component_name, ))
self.metadata = dict(component)
+++ /dev/null
-# Copyright (C) 2011,2012 Colin Walters <walters@verbum.org>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-# ostbuild-compile-one-make wraps systems that implement the GNOME build API:
-# http://people.gnome.org/~walters/docs/build-api.txt
-
-import os,sys,stat,subprocess,tempfile,re,shutil
-import argparse
-from StringIO import StringIO
-import json
-
-from . import builtins
-from .ostbuildlog import log, fatal
-from .subprocess_helpers import run_sync, run_sync_get_output
-from . import buildutil
-
-class OstbuildGenSnapshot(builtins.Builtin):
- name = "gen-snapshot"
- short_description = "Generate a snapshot description from a tree"
-
- def __init__(self):
- builtins.Builtin.__init__(self)
-
- def execute(self, argv):
- parser = argparse.ArgumentParser(description=self.short_description)
- parser.add_argument('--branch', required=True)
-
- args = parser.parse_args(argv)
- self.args = args
- self.parse_config()
-
- contents_json_text = run_sync_get_output(['ostree', '--repo=' + self.repo,
- 'cat', args.branch, 'contents.json'])
-
- contents = json.loads(contents_json_text)
- contents_list = contents['contents']
-
- base = contents_list[0]
- artifacts = contents_list[1:]
-
- components = []
- snapshot = {'name': args.branch,
- 'base': contents['base'],
- 'components': components}
-
- for artifact in artifacts:
- component_meta_text = run_sync_get_output(['ostree', '--repo=' + self.repo,
- 'cat', artifact['rev'], '/_ostbuild-meta.json'])
- component_meta = json.loads(component_meta_text)
- components.append(component_meta)
-
- json.dump(snapshot, sys.stdout)
-
-builtins.register(OstbuildGenSnapshot)
--- /dev/null
+# Copyright (C) 2011,2012 Colin Walters <walters@verbum.org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# ostbuild-compile-one-make wraps systems that implement the GNOME build API:
+# http://people.gnome.org/~walters/docs/build-api.txt
+
+import os,sys,stat,subprocess,tempfile,re,shutil
+import argparse
+from StringIO import StringIO
+import json
+
+from . import builtins
+from .ostbuildlog import log, fatal
+from .subprocess_helpers import run_sync, run_sync_get_output
+from . import buildutil
+
+class OstbuildQueryContent(builtins.Builtin):
+ name = "query-content"
+ short_description = "Output metadata from a component"
+
+ def __init__(self):
+ builtins.Builtin.__init__(self)
+
+ def execute(self, argv):
+ parser = argparse.ArgumentParser(description=self.short_description)
+ parser.add_argument('--branch', required=True)
+ parser.add_argument('--component')
+
+ args = parser.parse_args(argv)
+ self.args = args
+ self.parse_config()
+
+ contents_json_text = run_sync_get_output(['ostree', '--repo=' + self.repo,
+ 'cat', args.branch, 'contents.json'])
+
+ if args.component is None:
+ sys.stdout.write(contents_json_text)
+ else:
+ contents = json.loads(contents_json_text)
+ contents_list = contents['contents']
+ found = False
+ for content in contents_list:
+ if content['name'] != args.component:
+ found = True
+ break
+ if not found:
+ fatal("Unknown component '%s'" % (args.component, ))
+ ostbuildmeta_json = run_sync_get_output(['ostree', '--repo=' + self.repo,
+ 'cat', content['ostree-revision'],
+ '/_ostbuild-meta.json'])
+ sys.stdout.write(ostbuildmeta_json)
+
+builtins.register(OstbuildQueryContent)
component['patches']['files'] = patch_files
name_prefix = snapshot['name-prefix']
- del snapshot['name-prefix']
base_prefix = snapshot['base-prefix']
- del snapshot['base-prefix']
manifest_architectures = snapshot['architectures']
del snapshot['patches']
del snapshot['architectures']
- targets_json = {}
targets_list = []
- targets_json['targets'] = targets_list
+ snapshot['targets'] = targets_list
for architecture in manifest_architectures:
for target_component_type in ['runtime', 'devel']:
target = {}
component_ref['trees'] = ['/runtime', '/devel', '/doc']
contents.append(component_ref)
target['contents'] = contents
- out_targets = os.path.join(self.workdir, '%s-targets.json' % (name_prefix, ))
- f = open(out_targets, 'w')
- json.dump(targets_json, f, indent=4, sort_keys=True)
- f.close()
- print "Created: %s" % (out_targets, )
- out_components = os.path.join(self.workdir, '%s-components.json' % (name_prefix, ))
- f = open(out_components, 'w')
for component in components_by_name.itervalues():
del component['name']
- json.dump(components_by_name, f, indent=4, sort_keys=True)
+ snapshot['components'] = components_by_name
+
+ out_snapshot = os.path.join(self.workdir, '%s-snapshot.json' % (name_prefix, ))
+ f = open(out_snapshot, 'w')
+ json.dump(snapshot, f, indent=4, sort_keys=True)
f.close()
- print "Created: %s" % (out_components, )
+ print "Created: %s" % (out_snapshot, )
builtins.register(OstbuildResolve)
self.manifest = json.load(open(self.manifest_path))
self.name_prefix = self.manifest['name-prefix']
- def parse_components_and_targets(self):
+ def parse_snapshot(self):
self.parse_manifest()
- components_path = os.path.join(self.workdir, '%s-components.json' % (self.name_prefix, ))
- self.components = json.load(open(components_path))
- targets_path = os.path.join(self.workdir, '%s-targets.json' % (self.name_prefix, ))
- self.targets = json.load(open(targets_path))
+ snapshot_path = os.path.join(self.workdir, '%s-snapshot.json' % (self.name_prefix, ))
+ self.snapshot = json.load(open(snapshot_path))
def execute(self, args):
raise NotImplementedError()
from . import builtin_chroot_compile_one
from . import builtin_chroot_run_triggers
from . import builtin_compile_one
-from . import builtin_gen_snapshot
+from . import builtin_query_content
from . import builtin_resolve
from . import builtin_status